/**
 * LCS 01. 下载插件
 */
public class LeastMinutes {
    public static int leastMinutes(int n) {
        // 数学法
//        double d = Math.log(n) / Math.log(2);
//        return (d > (int)d ? (int)d + 1 : (int)d) + 1;

        // 动态规划
        int[] dp = new int[n + 1];
        dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            dp[i] = dp[(i + 1) / 2] + 1;
        }

        return dp[n];
    }

    public static void main(String[] args) {
        System.out.println(leastMinutes(9));
    }
}
